<%@ page 
	language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"
    import="com.cdshop.web.PageUtil"
%>
<jsp:useBean id="model" class="com.cdshop.mvc.LoginPM" scope="request"/>
<%	
	model.populate(pageContext);
%>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <title>用户登录</title>
  <%@ include file="../inc/default.jsp" %>
</head>
 <body>
 <div id="container" style="display:inline-table;">
	<div id="top_banner">
			<%  com.cdshop.entity.User user=PageUtil.loginUser(pageContext);
				if(user==null){%>
			<a href="javascript:HJS.login();void 0;" class="top_font">登录</a>
			<a href="javascript:HJS.register();void 0;" class="top_font">注册</a>
			<%}else{%>
			<span class="top_font">欢迎您 <%=user.getNickname() %></span>
			<a href="javascript:HJS.shoppingCart();void 0;" class="top_font">购物车   </a>
			<a href="javascript:HJS.profile();void 0;" class="top_font">个人情况    </a>
			<a href="javascript:HJS.logout();void 0;" class="top_font">退出</a>
			<%}%>
	</div>
	<%@ include file="../inc/head.jsp" %>
	<div id="content">
	
		<div align="center">
			<h1>用户登录</h1>
			<form id="loginForm" action="<%= request.getContextPath()%>/page/loginAction.jsp" method="post">
			<table align="center" width="400" border="0" cellpadding="0" cellspacing="0" style="table-layout:auto;">
			    <tr>
			      <td height="30" align="right">用户名：</td>
			      <td align="left"><input type="text" id="username" name="username" style="width:150px;" maxlength="32"/></td>
			    </tr>
			    <tr>
			      <td>&#32;</td>
			      <td align="left" height="15">
			      	 <span id="usernameMsg" class="message" style="color:red;font-size:12px"></span>
			      </td>
			    </tr>
			    <tr>
			      <td height="30" align="right">密码：</td>
			      <td align="left"><input type="password" id="password" name="password" style="width:150px;" maxlength="32"/></td>
			    </tr>
			    <tr>
			      <td>&#32;</td>
			      <td align="left" height="15">
			      	 <span id="passwordMsg" class="message" style="color:red;font-size:12px"></span>
			      </td>
			    </tr>
				<tr>
					<td height="40" colspan="2" align="center">
					<input type="submit" value="登录"/>
					<input type="reset" value="重置"/>
					</td>
				</tr>
		     </table>	 
		     </form>
		</div>  
	</div>
	<%@ include file="../inc/footer.jsp" %>
</div>
<script type="text/javascript">
//<![CDATA[
var PJS={
	init:function(){
		jQuery("#loginForm").unbind("submit").submit(function(){
			var ret= GJS.validate(
					{to:"#username",at:"#usernameMsg",rules:[["required","用户名必须填写"]]},
					{to:"#password",at:"#passwordMsg",rules:[["required","密码必须填写"]]});
			if(!ret)
				return false;
			ret = GJS.validateLogin("#username","#password","#passwordMsg","登录失败,用户名或密码错误!","/page/loginValidate.jsp");
			return ret;
		});
		jQuery("input:reset").click(function(){jQuery(".message").hide();});
		jQuery("#username").click(function(){jQuery("#usernameMsg").hide();});
		jQuery("#password").click(function(){jQuery("#passwordMsg").hide();});
	}
};
jQuery(PJS.init);
//]]>
</script>
</body>
</html>